package com.cloud.code.算法.链表;


class Solution {
    public ListNode removeElements(ListNode head, int val) {

        ListNode dummyHead = new ListNode();
        dummyHead.next = head;
        ListNode pre = dummyHead;
        while (pre.next != null){
            if (pre.next.val == val)
                pre.next = pre.next.next;
            else
                pre = pre.next;
        }

        return dummyHead.next;
    }
}